/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * teaInterface.java
 *
 * Created on 2011-4-28, 15:02:21
 */
package com.edu.kamai.client;

import com.edu.kamai.client.control.contestControl;
import com.edu.kamai.client.control.usrControl;
import com.edu.kamai.client.control.paperControl;
import com.edu.kamai.client.upload.UploadMP3;
import com.edu.kamai.client.upload.UploadPaper;
import com.edu.kamai.config.Constant;
import com.edu.kamai.utility.FileName;
import com.edu.kamai.webservice.paper.Paper;
import com.edu.kamai.webservice.user.User;
import com.edu.kamai.xml.beans.choiceXML;
import com.edu.kamai.xml.beans.paperXML;
import com.edu.kamai.xml.beans.reading.readingQuestion;
import com.edu.kamai.xml.beans.reading.readingXML;
import com.edu.kamai.xml.beans.speaking.speakingQuestion;
import com.edu.kamai.xml.beans.speaking.speakingXML;
import com.edu.kamai.xml.beans.writing.writingQuestion;
import com.edu.kamai.xml.beans.writing.writingXML;
import com.edu.kamai.xmlparser.paperGeneration;
import com.edu.kamai.xmlparser.reading.readingPaperGeneration;
import com.edu.kamai.xmlparser.speaking.speakingPaperGeneration;
import com.edu.kamai.xmlparser.writing.writingPaperGeneration;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class TeacherMain extends javax.swing.JFrame {

    /** Creates new form teaInterface */
    public TeacherMain(String tn) {
        initComponents();
        setNet();
        //refreshPendingList();
        //rxmls = new ArrayList<readingXML>();
        //rxml = new readingXML();
        teacherName = tn;
        pxml = null;
    }
    
    private void setNet(){
        try{
            InputStream in = getClass().getResourceAsStream(Constant.netiniFilePath);
            Scanner scan = new Scanner(in);
            List<String> netList = new ArrayList<String>();
            
            while(scan.hasNextLine()){
                String line = scan.nextLine();
                if(!line.equals("")){
                    if(!line.startsWith("#")){
                        netList.add(line);
                    }
                }
            }
            paperControl.setNetList(netList);
            contestControl.setNetList(netList);
            scan.close();
            in.close();
            
        }catch(Exception ex){
            ex.printStackTrace();
            //Control.setNetList(new ArrayList<String>());
        }
        paperControl.setServer();
        contestControl.setServer();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        TP_Main = new javax.swing.JTabbedPane();
        validation_page = new javax.swing.JPanel();
        refresh = new javax.swing.JButton();
        verify = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        pending_list = new javax.swing.JList();
        jPanel2 = new javax.swing.JPanel();
        readingPanel = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        MainTxt = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        rNextChoice = new javax.swing.JButton();
        rSaveNext = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        choiceTxt = new javax.swing.JTextArea();
        rUpload = new javax.swing.JButton();
        rAChoice = new javax.swing.JRadioButton();
        rBChoice = new javax.swing.JRadioButton();
        rCChoice = new javax.swing.JRadioButton();
        rDChoice = new javax.swing.JRadioButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        aTxt = new javax.swing.JTextArea();
        jScrollPane5 = new javax.swing.JScrollPane();
        bTxt = new javax.swing.JTextArea();
        jScrollPane6 = new javax.swing.JScrollPane();
        cTxt = new javax.swing.JTextArea();
        jScrollPane7 = new javax.swing.JScrollPane();
        dTxt = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane13 = new javax.swing.JScrollPane();
        LMainTxt = new javax.swing.JTextArea();
        jScrollPane17 = new javax.swing.JScrollPane();
        lDTxt = new javax.swing.JTextArea();
        lAChoice = new javax.swing.JRadioButton();
        lBChoice = new javax.swing.JRadioButton();
        lCChoice = new javax.swing.JRadioButton();
        lDChoice = new javax.swing.JRadioButton();
        lTitle = new javax.swing.JTextField();
        lDescription = new javax.swing.JTextField();
        LNextChoice = new javax.swing.JButton();
        jScrollPane18 = new javax.swing.JScrollPane();
        lATxt = new javax.swing.JTextArea();
        jScrollPane19 = new javax.swing.JScrollPane();
        lCTxt = new javax.swing.JTextArea();
        jScrollPane20 = new javax.swing.JScrollPane();
        lBTxt = new javax.swing.JTextArea();
        lMP3Path = new javax.swing.JTextField();
        LUpload = new javax.swing.JButton();
        LNextListening = new javax.swing.JButton();
        lTime = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        lKey = new javax.swing.JTextField();
        jScrollPane14 = new javax.swing.JScrollPane();
        LMainTxt1 = new javax.swing.JTextArea();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        sSaveNext = new javax.swing.JButton();
        sprepareTime = new javax.swing.JTextField();
        sreadTime = new javax.swing.JTextField();
        jScrollPane12 = new javax.swing.JScrollPane();
        sMaintxt = new javax.swing.JTextArea();
        sAddMP3 = new javax.swing.JButton();
        sUpload = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        sMP3Path = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        sKey = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        sTitle = new javax.swing.JTextField();
        writingPanel = new javax.swing.JPanel();
        wAddMP3 = new javax.swing.JButton();
        jScrollPane8 = new javax.swing.JScrollPane();
        wMainTxt = new javax.swing.JTextArea();
        wTitle = new javax.swing.JTextField();
        wKey = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        wMP3Path = new javax.swing.JTextField();
        jScrollPane9 = new javax.swing.JScrollPane();
        wDesc = new javax.swing.JTextArea();
        wSaveNext = new javax.swing.JButton();
        wUpload = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        wTimeLimit = new javax.swing.JTextField();
        contestPanel = new javax.swing.JPanel();
        jScrollPane11 = new javax.swing.JScrollPane();
        Tpapers = new javax.swing.JTable();
        BreadPaper = new javax.swing.JButton();
        BaddPapers = new javax.swing.JButton();
        BdelPaper = new javax.swing.JButton();
        paperList = new java.awt.List();
        BcreateContest = new javax.swing.JButton();
        TFcontestTitle = new javax.swing.JTextField();
        jScrollPane10 = new javax.swing.JScrollPane();
        TAcontestDes = new javax.swing.JTextArea();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        MI_Answer = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        refresh.setText("Refresh");
        refresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshActionPerformed(evt);
            }
        });

        verify.setText("Verify");
        verify.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                verifyActionPerformed(evt);
            }
        });

        pending_list.setVerifyInputWhenFocusTarget(false);
        //pending_list.setVisible(true);
        pending_list.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pending_listMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(pending_list);

        javax.swing.GroupLayout validation_pageLayout = new javax.swing.GroupLayout(validation_page);
        validation_page.setLayout(validation_pageLayout);
        validation_pageLayout.setHorizontalGroup(
            validation_pageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, validation_pageLayout.createSequentialGroup()
                .addGroup(validation_pageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 792, Short.MAX_VALUE)
                    .addGroup(validation_pageLayout.createSequentialGroup()
                        .addComponent(refresh)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 648, Short.MAX_VALUE)
                        .addComponent(verify)))
                .addContainerGap())
        );
        validation_pageLayout.setVerticalGroup(
            validation_pageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(validation_pageLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addGroup(validation_pageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(refresh)
                    .addComponent(verify))
                .addContainerGap(110, Short.MAX_VALUE))
        );

        TP_Main.addTab("validation", validation_page);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 802, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 464, Short.MAX_VALUE)
        );

        TP_Main.addTab("scenario", jPanel2);

        MainTxt.setColumns(20);
        MainTxt.setLineWrap(true);
        MainTxt.setRows(5);
        jScrollPane2.setViewportView(MainTxt);

        jLabel1.setText("Main:");

        rNextChoice.setText("Next Choice");
        rNextChoice.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rNextChoiceActionPerformed(evt);
            }
        });

        rSaveNext.setText("Next Reading");
        rSaveNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rSaveNextActionPerformed(evt);
            }
        });

        choiceTxt.setColumns(20);
        choiceTxt.setLineWrap(true);
        choiceTxt.setRows(3);
        jScrollPane3.setViewportView(choiceTxt);

        rUpload.setText("Upload");
        rUpload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rUploadActionPerformed(evt);
            }
        });

        buttonGroup1.add(rAChoice);
        rAChoice.setText("A");

        buttonGroup1.add(rBChoice);
        rBChoice.setText("B");

        buttonGroup1.add(rCChoice);
        rCChoice.setText("C");

        buttonGroup1.add(rDChoice);
        rDChoice.setText("D");

        aTxt.setColumns(20);
        aTxt.setRows(1);
        jScrollPane4.setViewportView(aTxt);

        bTxt.setColumns(20);
        bTxt.setRows(1);
        jScrollPane5.setViewportView(bTxt);

        cTxt.setColumns(20);
        cTxt.setRows(1);
        jScrollPane6.setViewportView(cTxt);

        dTxt.setColumns(20);
        dTxt.setRows(1);
        jScrollPane7.setViewportView(dTxt);

        jLabel2.setText("Choice:");

        javax.swing.GroupLayout readingPanelLayout = new javax.swing.GroupLayout(readingPanel);
        readingPanel.setLayout(readingPanelLayout);
        readingPanelLayout.setHorizontalGroup(
            readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(readingPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 391, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(45, 45, 45)
                .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)
                    .addGroup(readingPanelLayout.createSequentialGroup()
                        .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(readingPanelLayout.createSequentialGroup()
                                .addComponent(rBChoice)
                                .addGap(6, 6, 6))
                            .addGroup(readingPanelLayout.createSequentialGroup()
                                .addComponent(rCChoice)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                        .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(readingPanelLayout.createSequentialGroup()
                        .addComponent(rAChoice)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(rUpload, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(rSaveNext, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(rNextChoice, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(readingPanelLayout.createSequentialGroup()
                        .addComponent(rDChoice)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        readingPanelLayout.setVerticalGroup(
            readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(readingPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(readingPanelLayout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rAChoice))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rBChoice))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(rCChoice))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(readingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(readingPanelLayout.createSequentialGroup()
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(rNextChoice)
                                .addGap(18, 18, 18)
                                .addComponent(rSaveNext)
                                .addGap(18, 18, 18)
                                .addComponent(rUpload))
                            .addComponent(rDChoice))
                        .addGap(14, 14, 14))
                    .addGroup(readingPanelLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
                        .addContainerGap())))
        );

        TP_Main.addTab("reading", readingPanel);

        LMainTxt.setColumns(20);
        LMainTxt.setLineWrap(true);
        LMainTxt.setRows(3);
        jScrollPane13.setViewportView(LMainTxt);

        lDTxt.setColumns(20);
        lDTxt.setRows(1);
        jScrollPane17.setViewportView(lDTxt);

        lAChoice.setText("A");

        lBChoice.setText("B");

        lCChoice.setText("C");

        lDChoice.setText("D");

        lDescription.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lDescriptionActionPerformed(evt);
            }
        });

        LNextChoice.setText("Next Choice");

        lATxt.setColumns(20);
        lATxt.setRows(1);
        jScrollPane18.setViewportView(lATxt);

        lCTxt.setColumns(20);
        lCTxt.setRows(1);
        jScrollPane19.setViewportView(lCTxt);

        lBTxt.setColumns(20);
        lBTxt.setRows(1);
        jScrollPane20.setViewportView(lBTxt);

        lMP3Path.setEditable(false);
        lMP3Path.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lMP3PathMouseClicked(evt);
            }
        });
        lMP3Path.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lMP3PathActionPerformed(evt);
            }
        });

        LUpload.setText("Upload");

        LNextListening.setText("Next Listening");

        jLabel15.setText("Time");

        jLabel16.setText("Key");

        LMainTxt1.setColumns(20);
        LMainTxt1.setLineWrap(true);
        LMainTxt1.setRows(3);
        jScrollPane14.setViewportView(LMainTxt1);

        jLabel17.setText("Description");

        jLabel18.setText("Title");

        jLabel19.setText("Choice");

        jLabel20.setText("Main");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lDChoice)
                            .addComponent(lBChoice))
                        .addComponent(lAChoice))
                    .addComponent(lCChoice))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane14, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                            .addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                            .addComponent(jScrollPane19, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                            .addComponent(LNextChoice, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane18, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                            .addComponent(jScrollPane20, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)
                            .addComponent(jScrollPane17, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE))
                        .addGap(38, 38, 38)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                    .addComponent(jLabel15)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(lTime, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18)
                                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(lKey)
                                        .addComponent(LNextListening, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(LUpload, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addComponent(lTitle)
                                .addComponent(lDescription)
                                .addComponent(lMP3Path, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE))
                            .addComponent(jLabel17))))
                .addContainerGap())
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGap(49, 49, 49)
                    .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(723, Short.MAX_VALUE)))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(lTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(24, 24, 24)
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lDescription, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                                .addComponent(lMP3Path, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(30, 30, 30)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel15)
                                    .addComponent(lKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel16))
                                .addGap(36, 36, 36)
                                .addComponent(LNextListening))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jScrollPane14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(lAChoice)
                                    .addComponent(jScrollPane18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lBChoice)
                                    .addComponent(jScrollPane20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(14, 14, 14)))
                        .addGap(32, 32, 32)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jScrollPane17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(LNextChoice)
                                    .addComponent(LUpload)))
                            .addComponent(lDChoice))
                        .addContainerGap())
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 149, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lCChoice)
                            .addComponent(jScrollPane19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(79, 79, 79))))
            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGap(39, 39, 39)
                    .addComponent(jLabel20)
                    .addContainerGap(410, Short.MAX_VALUE)))
        );

        TP_Main.addTab("listening", jPanel3);

        sSaveNext.setText("Next Speaking");
        sSaveNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sSaveNextActionPerformed(evt);
            }
        });

        sMaintxt.setColumns(20);
        sMaintxt.setLineWrap(true);
        sMaintxt.setRows(5);
        jScrollPane12.setViewportView(sMaintxt);

        sAddMP3.setText("Add MP3");
        sAddMP3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sAddMP3ActionPerformed(evt);
            }
        });

        sUpload.setText("Upload");
        sUpload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sUploadActionPerformed(evt);
            }
        });

        jLabel10.setText("Main:");

        jLabel11.setText("prepare:");

        jLabel12.setText("reading:");

        sMP3Path.setEditable(false);

        jLabel13.setText("Key:");

        jLabel14.setText("Title:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addGap(762, 762, 762))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(sTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
                .addGap(384, 384, 384))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addComponent(sAddMP3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 364, Short.MAX_VALUE)
                        .addComponent(sSaveNext))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(18, 18, 18)
                                .addComponent(sprepareTime, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 340, Short.MAX_VALUE)
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(sreadTime, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(sMP3Path, javax.swing.GroupLayout.DEFAULT_SIZE, 618, Short.MAX_VALUE))))
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addComponent(jLabel13)
                        .addGap(18, 18, 18)
                        .addComponent(sKey, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sUpload)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(sTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(sKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(sreadTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12)
                            .addComponent(sprepareTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(sMP3Path, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(sAddMP3)
                            .addComponent(sSaveNext)
                            .addComponent(sUpload))
                        .addGap(27, 27, 27))))
        );

        TP_Main.addTab("speaking", jPanel4);

        wAddMP3.setText("Add MP3");
        wAddMP3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wAddMP3ActionPerformed(evt);
            }
        });

        wMainTxt.setColumns(20);
        wMainTxt.setLineWrap(true);
        wMainTxt.setRows(5);
        jScrollPane8.setViewportView(wMainTxt);

        wTitle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wTitleActionPerformed(evt);
            }
        });

        jLabel3.setText("Title:");

        jLabel4.setText("Key:");

        jLabel5.setText("Description:");

        wMP3Path.setEditable(false);

        wDesc.setColumns(20);
        wDesc.setLineWrap(true);
        wDesc.setRows(5);
        jScrollPane9.setViewportView(wDesc);

        wSaveNext.setText("Next Writting");
        wSaveNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wSaveNextActionPerformed(evt);
            }
        });

        wUpload.setText("Upload");
        wUpload.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wUploadActionPerformed(evt);
            }
        });

        jLabel6.setText("Main:");

        jLabel7.setText("Time Limit:");

        javax.swing.GroupLayout writingPanelLayout = new javax.swing.GroupLayout(writingPanel);
        writingPanel.setLayout(writingPanelLayout);
        writingPanelLayout.setHorizontalGroup(
            writingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(writingPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(writingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(writingPanelLayout.createSequentialGroup()
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 394, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(41, 41, 41)
                        .addGroup(writingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(wTitle, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jScrollPane9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addComponent(jLabel5)
                            .addComponent(wMP3Path, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                            .addGroup(writingPanelLayout.createSequentialGroup()
                                .addComponent(wAddMP3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                                .addComponent(wSaveNext)
                                .addGap(43, 43, 43)
                                .addComponent(wUpload))
                            .addGroup(writingPanelLayout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(wKey, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel4)
                                .addGap(18, 18, 18)
                                .addComponent(wTimeLimit, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)))
                        .addContainerGap())
                    .addComponent(jLabel6)))
        );
        writingPanelLayout.setVerticalGroup(
            writingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(writingPanelLayout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(writingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, writingPanelLayout.createSequentialGroup()
                        .addGroup(writingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(wTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(wKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(wTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(19, 19, 19)
                        .addComponent(wMP3Path, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(writingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(wUpload)
                            .addComponent(wAddMP3)
                            .addComponent(wSaveNext)))
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE))
                .addGap(30, 30, 30))
        );

        TP_Main.addTab("writing", writingPanel);

        /*
        Tpapers.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null}
            },
            new String [] {
                "Title", "Type", "Time"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        Tpapers.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        */
        jScrollPane11.setViewportView(Tpapers);

        BreadPaper.setText("READ");
        BreadPaper.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BreadPaperActionPerformed(evt);
            }
        });

        BaddPapers.setText("ADD");
        BaddPapers.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BaddPapersActionPerformed(evt);
            }
        });

        BdelPaper.setText("DEL");
        BdelPaper.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BdelPaperActionPerformed(evt);
            }
        });

        BcreateContest.setText("Create");
        BcreateContest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BcreateContestActionPerformed(evt);
            }
        });

        TAcontestDes.setColumns(20);
        TAcontestDes.setRows(5);
        jScrollPane10.setViewportView(TAcontestDes);

        jLabel8.setText("Title:");

        jLabel9.setText("Description:");

        javax.swing.GroupLayout contestPanelLayout = new javax.swing.GroupLayout(contestPanel);
        contestPanel.setLayout(contestPanelLayout);
        contestPanelLayout.setHorizontalGroup(
            contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(contestPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 358, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BcreateContest, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(contestPanelLayout.createSequentialGroup()
                        .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(BdelPaper, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(BaddPapers, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(BreadPaper, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(28, 28, 28)
                        .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(contestPanelLayout.createSequentialGroup()
                                .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jScrollPane10)
                                    .addComponent(TFcontestTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)))
                            .addComponent(paperList, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(58, Short.MAX_VALUE))
        );
        contestPanelLayout.setVerticalGroup(
            contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, contestPanelLayout.createSequentialGroup()
                .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(contestPanelLayout.createSequentialGroup()
                        .addGap(43, 43, 43)
                        .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, contestPanelLayout.createSequentialGroup()
                                .addComponent(BreadPaper, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(33, 33, 33)
                                .addComponent(BaddPapers, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                                .addComponent(BdelPaper, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(paperList, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE))
                        .addGap(19, 19, 19)
                        .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TFcontestTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(contestPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(contestPanelLayout.createSequentialGroup()
                                .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(BcreateContest, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel9)))
                    .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE))
                .addContainerGap())
        );

        TP_Main.addTab("Contest", contestPanel);

        jMenu1.setText("File");

        jMenuItem1.setText("Open Paper");
        jMenu1.add(jMenuItem1);

        MI_Answer.setText("Answer");
        MI_Answer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MI_AnswerActionPerformed(evt);
            }
        });
        jMenu1.add(MI_Answer);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(TP_Main, javax.swing.GroupLayout.PREFERRED_SIZE, 807, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TP_Main, javax.swing.GroupLayout.DEFAULT_SIZE, 493, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void showMessage(int ans,String msg){
        if(ans == 1){
            javax.swing.JOptionPane.showMessageDialog(this, msg, "Done", ans);
        }else{
            javax.swing.JOptionPane.showMessageDialog(this, msg, "Error", ans);
        }
    }
    
    private String getChoiceKey(){
        if(rAChoice.isSelected()){
            return "A";
        }else if (rBChoice.isSelected()){
            return "B";
        }else if(rCChoice.isSelected()){
            return "C";
        }else{
            return "D";
        }
    }
    
    private void verifyUsr(){
        Object[] selected = pending_list.getSelectedValues();
        
        for(int i=0;i<selected.length;i++){
            String tmpValue = selected[i].toString();
            String[] values = tmpValue.split(":");
            String usrID  = values[0];
            String usrEmail = values[1];
            int role = values[2].equals("student")?Constant.KAMAI_STUDENT_ROLE:Constant.KAMAI_TEACHER_ROLE;
            System.out.println(usrID + " " + usrEmail + " " + role);
            int ans = usrControl.validateUsr(usrID);
            showMessage(ans,usrControl.getMessage());
        }
        refreshPendingList();
    }
    
    private void refreshPendingList(){
        List<User> pending = usrControl.chekPendingList();
        sampleModel = new DefaultListModel();
        pending_list.setModel(sampleModel);
        //Vector<String> v = new Vector<String>();
        if(pending.isEmpty()){
            showMessage(1,usrControl.getMessage());
        }else{
            sampleModel.removeAllElements();
            for(int i=0;i<pending.size();i++){
                User user = pending.get(i);
                String usrID = user.getUserId();
                String usrEmail = user.getEmail();
                int role = user.getRole();
                String sRole = (role == Constant.KAMAI_STUDENT_ROLE?"student":"teacher");
                String result = usrID + ":"+usrEmail+":"+sRole;
                System.out.println(result);
                sampleModel.addElement(result);
            }
        }
    }
        
    private String getFilePath(){
        JFileChooser chooser = new JFileChooser("./");
        String res = null;
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            try{
                res = chooser.getSelectedFile().getAbsolutePath();
            }catch(Exception ex){
                ex.printStackTrace();
            }
        }
        return res;
    }
    
    private void clearSpeakingXML(){
        sMaintxt.setText("");
        sprepareTime.setText("");
        sTitle.setText("");
        sreadTime.setText("");
        sMP3Path.setText("");
    }
    
    private void clearWritingXML(){
        wMainTxt.setText("");
        wTimeLimit.setText("");
        wDesc.setText("");
        wMP3Path.setText("");
        wTitle.setText("");
    }
       
    private void TP_MainStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TP_MainStateChanged
        // TODO add your handling code here:
        //javax.swing.JOptionPane.showMessageDialog(this, "HELLO", "Done", 1);
        
    }//GEN-LAST:event_TP_MainStateChanged

    private void contestPanelFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_contestPanelFocusGained
        // TODO add your handling code here:
       
    }//GEN-LAST:event_contestPanelFocusGained

    private void BreadContestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BreadContestActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_BreadContestActionPerformed

    private void BcreateContestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BcreateContestActionPerformed
        // TODO add your handling code here:
        //String[] selectedItem = paperList.getSelectedItems();
        String[] selectedItem = paperList.getItems();
        int rID,lID,sID,wID;
        rID = lID = sID = wID = -1;
        if(selectedItem.length >= 5){
            javax.swing.JOptionPane.showMessageDialog(this, "Too Many Papers!", "Error", 0);
            return;
        }
        
        for(int i=0;i<selectedItem.length;i++){
            String[] tmp = selectedItem[i].split("@");
            int id = Integer.parseInt(tmp[0]);
            String type = tmp[2];
            
            //HARD CODE
            if(type.equals("READING")){
                rID = id;
            }else if(type.equals("LISTENING")){
                lID = id;
            }else if(type.equals("SPEAKING")){
                sID = id;
            }else if(type.equals("WRITING")){
                wID = id;
            }
            //HARD CODE
        }
        
        System.out.println(rID + " " + lID + " " + sID +  " " + wID);
        
        String cTitle = TFcontestTitle.getText();
        String cDesc = TAcontestDes.getText();
        if(cTitle.equals("") || cDesc.equals("")){
            javax.swing.JOptionPane.showMessageDialog(this, "Please fill in the "
                    + "information", "Error", 0);
            return;
        }
        int ans = contestControl.addContest(cTitle, cDesc, cDesc, rID, sID, wID, lID);
        showMessage(ans, contestControl.getMessage());
}//GEN-LAST:event_BcreateContestActionPerformed

    private void BdelPaperActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BdelPaperActionPerformed
        // TODO add your handling code here:
        int[] delSelected = paperList.getSelectedIndexes();
        for(int i=0;i<delSelected.length;i++){
            paperList.remove(delSelected[i]);
        }
}//GEN-LAST:event_BdelPaperActionPerformed

    private void BaddPapersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BaddPapersActionPerformed
        // TODO add your handling code here:
        int[] selected = Tpapers.getSelectedRows();
        //System.out.println(selected.length);
        for(int i=0;i<selected.length;i++){
            String id = (String)(Tpapers.getValueAt(selected[i], 0));
            String title = (String)(Tpapers.getValueAt(selected[i], 1));
            String type = (String)(Tpapers.getValueAt(selected[i], 2));
            paperList.add(id + "@" + title + "@" + type);
        }
}//GEN-LAST:event_BaddPapersActionPerformed

    private void BreadPaperActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BreadPaperActionPerformed
        // TODO add your handling code here:
        List<Paper> readPapers = null;
        //readPapers = paperControl.findPaperByRoleID(Constant.WRITING_PAPER_ID);
        readPapers = paperControl.findPapers();
        //Tpapers.setAutoCreateRowSorter(true);
        myDefaultTableModel model = new myDefaultTableModel();
        Tpapers.setModel(model);
        
        model.addColumn("PaperID");
        model.addColumn("PaperTitle");
        model.addColumn("PaperType");
        for(int i=0;i<readPapers.size();i++){
            Paper tmp = readPapers.get(i);
            String id = Integer.toString(tmp.getPaperId());
            String title =  tmp.getTitle();
            String type = Constant.paperRoleTable[tmp.getStatus()];
            //String creatTime = tmp.getStartTime().toString();
            model.insertRow(i, new Object[]{id,title,type});
        }
    }//GEN-LAST:event_BreadPaperActionPerformed

    private void wUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wUploadActionPerformed
        
        /*upload mp3 file && modify the mp3 path value in paper xml*/
        writingXML wxml = (writingXML)pxml;
        UploadMP3 up = new UploadMP3();
        UploadPaper upp = new UploadPaper();
        
        for(int i=0;i<wxml.getWritingquestionList().size();i++){
            String name = wxml.getWritingquestionList().get(i).getMp3Path();
            up.addMP3Path(name);
            wxml.getWritingquestionList().get(i).setMp3Path(
                                        FileName.reFullPathWithTime(name));
        }
        up.start();
        /*upload mp3 file && modify the mp3 path value in paper xml*/
        
        /*generate the xml file*/
        String paperName = "";
        if(pxml != null){
            paperGeneration pg = new writingPaperGeneration(pxml);
            pg.generateBody();
            paperName = FileName.reNameWithCurrentTime(teacherName);
            System.out.println(paperName);
            pg.writeToDisk(paperName);
        }else{
            showMessage(0, "Error no xml information!");
            System.out.println("Error no xml information!");
        }
        /*generate the xml file*/
        
        /*upload xml file*/
        upp.setFileName(paperName);
        upp.start();
        /*upload xml file*/
        
        /*insert the data into database*/
        String paperTitle =
                JOptionPane.showInputDialog
                ("Please Input the Paper Title.");
        
        String paperDesc =
                JOptionPane.showInputDialog
                ("Please Input the Paper Description.");
        
        int ans = paperControl.addOnePaper(
                Constant.upLoadPaperFileFolder + "/" + paperName + ".xml",
                wKey.getText(),paperTitle,paperDesc, Constant.WRITING_PAPER_ID);
        showMessage(ans, paperControl.getMessage());
        /*insert the data into database*/
        
        /*free pxml*/
        pxml = null;
        /*free pxml*/
}//GEN-LAST:event_wUploadActionPerformed

    private void wSaveNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wSaveNextActionPerformed
        // TODO add your handling code here:
        if(null == pxml){
            //create a paper
            pxml = new writingXML();
            pxml.setPaperKey(wKey.getText());
        }
        
        //add a question into a paper
        writingQuestion wq = new writingQuestion();
        wq.setMainTxt(wMainTxt.getText());
        wq.setTimeLimit(wTimeLimit.getText());
        wq.setPaperDescription(wDesc.getText());
        wq.setMp3Path(wMP3Path.getText());
        wq.setPaperTitle(wTitle.getText());
        
        pxml.addWritingQuestionToPaper(wq);
        clearWritingXML();
}//GEN-LAST:event_wSaveNextActionPerformed

    private void wTitleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wTitleActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_wTitleActionPerformed

    private void wAddMP3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wAddMP3ActionPerformed
        // TODO add your handling code here:
        wMP3Path.setText(getFilePath());
}//GEN-LAST:event_wAddMP3ActionPerformed

    private void rUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rUploadActionPerformed
        
        readingXML rxml = (readingXML)pxml;
        UploadPaper upp = new UploadPaper();
        
        /*generate the xml file*/
        String paperName = "";
        if(pxml != null){
            paperGeneration pg = new readingPaperGeneration(pxml);
            pg.generateBody();
            paperName = FileName.reNameWithCurrentTime(teacherName);
            System.out.println(paperName);
            pg.writeToDisk(paperName);
        }else{
            showMessage(0, "Error no xml information!");
            System.out.println("Error no xml information!");
        }
        /*generate the xml file*/
        
        /*upload xml file*/
        upp.setFileName(paperName);
        upp.start();
        /*upload xml file*/
        
        /*insert the data into database*/
        String paperTitle =
                JOptionPane.showInputDialog
                ("Please Input the Paper Title.");
        
        String paperDesc =
                JOptionPane.showInputDialog
                ("Please Input the Paper Description.");
        
        int ans = paperControl.addOnePaper(
                Constant.upLoadPaperFileFolder + "/" + paperName + ".xml",
                sKey.getText(),paperTitle,paperDesc, Constant.READING_PAPER_ID);
        showMessage(ans, paperControl.getMessage());
        /*insert the data into database*/
        
        /*free pxml*/
        pxml = null;
        /*free pxml*/
}//GEN-LAST:event_rUploadActionPerformed

    private void rSaveNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rSaveNextActionPerformed
        nextReading();
}//GEN-LAST:event_rSaveNextActionPerformed

    private void rNextChoiceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rNextChoiceActionPerformed
        nextChoice();
}//GEN-LAST:event_rNextChoiceActionPerformed

    private void pending_listMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pending_listMouseClicked
        // TODO add your handling code here:
        if(evt.getClickCount() == 2){
            verifyUsr();
        }
}//GEN-LAST:event_pending_listMouseClicked

    private void verifyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verifyActionPerformed
        // TODO add your handling code here:
        verifyUsr();
}//GEN-LAST:event_verifyActionPerformed

    private void refreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshActionPerformed
        refreshPendingList();
}//GEN-LAST:event_refreshActionPerformed

    private void MI_AnswerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MI_AnswerActionPerformed
        // TODO add your handling code here:
        //System.out.println("okkkok");
        AnswerFrm af = new AnswerFrm(teacherName);
        af.setVisible(true);
        
    }//GEN-LAST:event_MI_AnswerActionPerformed

    private void sAddMP3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sAddMP3ActionPerformed
        // TODO add your handling code here:
        sMP3Path.setText(getFilePath());
    }//GEN-LAST:event_sAddMP3ActionPerformed

    private void sSaveNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sSaveNextActionPerformed
        // TODO add your handling code here:
        if(null == pxml){
            //create a paper
            pxml = new speakingXML();
            pxml.setPaperKey(sKey.getText());
        }
        
        //add a question into a paper
        speakingQuestion sq = new speakingQuestion();
        sq.setMainTxt(sMaintxt.getText());
        sq.setPaperTitle(sTitle.getText());
        sq.setPrepareTime(sprepareTime.getText());
        sq.setReadingTime(sreadTime.getText());
        sq.setMp3Path(sMP3Path.getText());
        pxml.addSpeakingQuestionToPaper(sq);
        
        clearSpeakingXML();
    }//GEN-LAST:event_sSaveNextActionPerformed

    private void sUploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sUploadActionPerformed
        // TODO add your handling code here:
        
        /*upload mp3 file && modify the mp3 path value in paper xml*/
        speakingXML wxml = (speakingXML)pxml;
        UploadMP3 up = new UploadMP3();
        UploadPaper upp = new UploadPaper();
        
        for(int i=0;i<wxml.getSpeakingquestionList().size();i++){
            String name = wxml.getSpeakingquestionList().get(i).getMp3Path();
            up.addMP3Path(name);
            wxml.getSpeakingquestionList().get(i).setMp3Path(FileName.reFullPathWithTime(name));
        }
        up.start();
        /*upload mp3 file && modify the mp3 path value in paper xml*/
        
        /*generate the xml file*/
        String paperName = "";
        if(pxml != null){
            paperGeneration pg = new speakingPaperGeneration(pxml);
            pg.generateBody();
            paperName = FileName.reNameWithCurrentTime(teacherName);
            System.out.println(paperName);
            pg.writeToDisk(paperName);
        }else{
            showMessage(0, "Error no xml information!");
            System.out.println("Error no xml information!");
        }
        /*generate the xml file*/
        
        /*upload xml file*/
        upp.setFileName(paperName);
        upp.start();
        /*upload xml file*/
        
        /*insert the data into database*/
        String paperTitle =
                JOptionPane.showInputDialog
                ("Please Input the Paper Title.");
        
        String paperDesc =
                JOptionPane.showInputDialog
                ("Please Input the Paper Description.");
        
        int ans = paperControl.addOnePaper(
                Constant.upLoadPaperFileFolder + "/" + paperName + ".xml",
                sKey.getText(),paperTitle,paperDesc, Constant.SPEAKING_PAPER_ID);
        showMessage(ans, paperControl.getMessage());
        /*insert the data into database*/
        
        /*free pxml*/
        pxml = null;
        /*free pxml*/
        
    }//GEN-LAST:event_sUploadActionPerformed

    private void lDescriptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lDescriptionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_lDescriptionActionPerformed

    private void lMP3PathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lMP3PathActionPerformed
        // TODO add your handling code here:
        
    }//GEN-LAST:event_lMP3PathActionPerformed

    private void lMP3PathMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lMP3PathMouseClicked
        // TODO add your handling code here:
        
    }//GEN-LAST:event_lMP3PathMouseClicked
    
    
    private void nextReading(){
        if(pxml == null){
            pxml = new readingXML();
        }
        readingQuestion rq = new readingQuestion();
        rq.setMainTxt(MainTxt.getText());
        rq.setChoices(choices);
        pxml.addReadingQuestionToPaper(rq);
        
        choices = null;
        
        clearChoices();
        MainTxt.setText("");
    }
    
    private void nextChoice(){
        if(choices == null){
            choices = new ArrayList<choiceXML>();
        }
        choiceXML tmp = new choiceXML(false);
        tmp.setMainTxt(choiceTxt.getText());
        tmp.getChoicesTxt().add(aTxt.getText());
        tmp.getChoicesTxt().add(bTxt.getText());
        tmp.getChoicesTxt().add(cTxt.getText());
        tmp.getChoicesTxt().add(dTxt.getText());
        tmp.getKey().add(getChoiceKey());
        choices.add(tmp);
        /*
        rxml.addOneChoice(tmp);
         * 
         */
        clearChoices();
    }
    
    private void clearChoices(){
        choiceTxt.setText("");
        aTxt.setText("");
        bTxt.setText("");
        cTxt.setText("");
        dTxt.setText("");
        rAChoice.setSelected(true);
    }
    
    private void clearAllTxtFields(){
        clearChoices();
        MainTxt.setText("");
    }
    private DefaultListModel listModel; //= new DefaultListModel();
    private DefaultListModel sampleModel;
    private paperXML pxml;
    private String teacherName;
    
    private List<choiceXML> choices;
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BaddPapers;
    private javax.swing.JButton BcreateContest;
    private javax.swing.JButton BdelPaper;
    private javax.swing.JButton BreadPaper;
    private javax.swing.JTextArea LMainTxt;
    private javax.swing.JTextArea LMainTxt1;
    private javax.swing.JButton LNextChoice;
    private javax.swing.JButton LNextListening;
    private javax.swing.JButton LUpload;
    private javax.swing.JMenuItem MI_Answer;
    private javax.swing.JTextArea MainTxt;
    private javax.swing.JTextArea TAcontestDes;
    private javax.swing.JTextField TFcontestTitle;
    private javax.swing.JTabbedPane TP_Main;
    private javax.swing.JTable Tpapers;
    private javax.swing.JTextArea aTxt;
    private javax.swing.JTextArea bTxt;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JTextArea cTxt;
    private javax.swing.JTextArea choiceTxt;
    private javax.swing.JPanel contestPanel;
    private javax.swing.JTextArea dTxt;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane17;
    private javax.swing.JScrollPane jScrollPane18;
    private javax.swing.JScrollPane jScrollPane19;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane20;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JRadioButton lAChoice;
    private javax.swing.JTextArea lATxt;
    private javax.swing.JRadioButton lBChoice;
    private javax.swing.JTextArea lBTxt;
    private javax.swing.JRadioButton lCChoice;
    private javax.swing.JTextArea lCTxt;
    private javax.swing.JRadioButton lDChoice;
    private javax.swing.JTextArea lDTxt;
    private javax.swing.JTextField lDescription;
    private javax.swing.JTextField lKey;
    private javax.swing.JTextField lMP3Path;
    private javax.swing.JTextField lTime;
    private javax.swing.JTextField lTitle;
    private java.awt.List paperList;
    private javax.swing.JList pending_list;
    private javax.swing.JRadioButton rAChoice;
    private javax.swing.JRadioButton rBChoice;
    private javax.swing.JRadioButton rCChoice;
    private javax.swing.JRadioButton rDChoice;
    private javax.swing.JButton rNextChoice;
    private javax.swing.JButton rSaveNext;
    private javax.swing.JButton rUpload;
    private javax.swing.JPanel readingPanel;
    private javax.swing.JButton refresh;
    private javax.swing.JButton sAddMP3;
    private javax.swing.JTextField sKey;
    private javax.swing.JTextField sMP3Path;
    private javax.swing.JTextArea sMaintxt;
    private javax.swing.JButton sSaveNext;
    private javax.swing.JTextField sTitle;
    private javax.swing.JButton sUpload;
    private javax.swing.JTextField sprepareTime;
    private javax.swing.JTextField sreadTime;
    private javax.swing.JPanel validation_page;
    private javax.swing.JButton verify;
    private javax.swing.JButton wAddMP3;
    private javax.swing.JTextArea wDesc;
    private javax.swing.JTextField wKey;
    private javax.swing.JTextField wMP3Path;
    private javax.swing.JTextArea wMainTxt;
    private javax.swing.JButton wSaveNext;
    private javax.swing.JTextField wTimeLimit;
    private javax.swing.JTextField wTitle;
    private javax.swing.JButton wUpload;
    private javax.swing.JPanel writingPanel;
    // End of variables declaration//GEN-END:variables
}
